Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events: do not read garbage memory on empty control files #724

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

pkova
Copy link
Collaborator

@pkova pkova commented Oct 3, 2024

This is another one of the address sanitizer catches.

For whatever reason my directed messaging fakeship ended up in a situation with empty control.bin and memory.bin. When starting up this fakeship the address sanitizer blows up here:

vere/pkg/noun/events.c

Lines 459 to 467 in f5799a9

pat_u->con_u = c3_malloc(len_w);
if ( (len_w != read(pat_u->ctl_i, pat_u->con_u, len_w)) ||
(len_w != sizeof(u3e_control) +
(pat_u->con_u->pgs_w * sizeof(u3e_line))) )
{
c3_free(pat_u->con_u);
pat_u->con_u = 0;
return c3n;
}

len_w is 0, malloc(0) is implementation defined but does give a non-null pointer on macos, which means that on line 462 we are reading random garbage.

@pkova pkova requested a review from a team as a code owner October 3, 2024 13:42
@pkova pkova merged commit ec54a66 into develop Oct 4, 2024
5 checks passed
@pkova pkova deleted the pkova/control branch October 4, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant